package com.codi.bus.core.resultModel;

import com.alibaba.fastjson.annotation.JSONField;
import com.codi.base.util.DateUtils;
import com.codi.base.util.MoneyUtils;
import com.codi.bus.core.service.model.PortfolioModel;
import lombok.Data;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 资产页面 组合
 * Created by asus on 2017/11/7.
 */
@Data
@Accessors(chain = true)
public class AssetsPortfolioResult extends BaseResult{
    /**
     * 组合
     */
    private List<PortfolioModel> portfolios;

    /**
     * 组合总资产
     */
    private BigDecimal portfolioWorthValue;

    public String getPortfolioWorthValueString() {

        return MoneyUtils.formatMoney(this.portfolioWorthValue, 2);
    }

    /**
     * 组合总当日收益
     */
    private BigDecimal portfolioTodayIncome;

    public String getPortfolioTodayIncomeString(){
        return MoneyUtils.formatMoney(this.portfolioTodayIncome, 2);
    }

    /**
     * 组合总持仓收益
     */
    private BigDecimal portfolioShareIncome;

    public String getPortfolioShareIncomeString(){
        return MoneyUtils.formatMoney(this.portfolioShareIncome, 2);
    }

    /**
     * 组合总持仓收益
     */
    private BigDecimal portfolioAccumIncome;

    public String getPortfolioAccumIncomeString(){
        return MoneyUtils.formatMoney(this.portfolioAccumIncome, 2);
    }

    /**
     * 是否有在途
     */
    @JSONField(serialize = false)
    private boolean inTransit;


    /**
     * 在途金额
     */
    private BigDecimal inTransitAmount;

    public String getInTransitAmountString(){
        if (inTransitAmount != null && inTransitAmount.doubleValue() != 0.00 ) {
            StringBuffer sb = new StringBuffer();
            sb.append("买入待确认");
            sb.append(MoneyUtils.formatMoney(inTransitAmount));
            return sb.toString();
        }
        return "";
    }



    /**
     * 在途中笔数
     */
    private Integer inTransitNum;

    public String getInTransitNumString() {
        if (inTransitNum != null && inTransitNum != 0) {
            StringBuffer sb = new StringBuffer();
            sb.append("有");
            sb.append(inTransitNum);
            sb.append("笔买入确认中");
            return sb.toString();
        }
        return "";
    }

    /**
     * 净值日期
     */
    @JSONField(serialize = false)
    private Date netValueDate;

    // 净值日期字符串 MM-dd
    public String getNetValueDateString() {
        if (this.netValueDate != null) {
            return DateUtils.formatDate7(this.netValueDate);
        } else {
            return "";
        }
    }

}

